#pragma once
int write_output_allmomenta(char *output, complex **input,double *p2,int nmom)
{
         complex *aux_clust=malloc(sizeof(complex)*(Nclust+1));
	 printf("Writing %s\n",output);
         FILE *fout=fopen(output,"w");
         if(fout == (FILE *)NULL) {
                fprintf(stderr,"Unable to open file %s for writing\n",output);
		return EXIT_FAILURE;
         }
	 for (int imom=0; imom<nmom; imom++)
         {
                          for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                          fprintf(fout,"%8.10f \t %8.10f %8.10f  + I %8.10f %8.10f \n",p2[imom],creal(input[imom][Nclust]),creal(error_jack(aux_clust,Nclust)),cimag(input[imom][Nclust]),cimag(error_jack(aux_clust,Nclust)));
	}


        fclose(fout);
	return 0;
}

int write_output_momentabymomenta(char *dir,char *file, complex **input, double *p2,int nmom)
{
         complex *aux_clust=malloc(sizeof(complex)*(Nclust+1));
         printf("Writing %s momenta by momenta in %s\n",file,dir);
	 char outputmom[1024];
	
	// jk
         for (int imom=0; imom<nmom; imom++)
         {
		sprintf(outputmom,"%s/p%03d/%s.jk",dir,imom,file);
		FILE *fout=fopen(outputmom,"w");
        	if(fout == (FILE *)NULL) {
	        	fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
	                return EXIT_FAILURE;
        	 }

//                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f \n",creal(input[imom][iclust]));
		 fclose(fout);
        }
	// dat
         for (int imom=0; imom<nmom; imom++)
         {
                sprintf(outputmom,"%s/p%03d/%s.dat",dir,imom,file);
                FILE *fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                 fprintf(fout,"%8.10f %8.10f %8.10f \n",p2[imom],creal(input[imom][Nclust]),creal(error_jack(aux_clust,Nclust)));
                 fclose(fout);
        }

        return 0;
}
int write_output_allmomenta_real(char *output, double **input, double *p2, int Nmom)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

//         printf("Writing in %s\n",output);
         FILE *fout=fopen(output,"w");
         if(fout == (FILE *)NULL) {
                fprintf(stderr,"Unable to open file %s for writing\n",output);
                return EXIT_FAILURE;
         }
         for (int imom=0; imom<Nmom; imom++)
         {
                          for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                          fprintf(fout,"%8.10f \t %8.10f %8.10f  \n",p2[imom],input[imom][Nclust],error_jack_real(aux_clust,Nclust));
        }


        fclose(fout);
        return 0;
}
int write_output_allmomenta_eq_real(char *output, double **input, double *p2)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

         printf("Writing in %s\n",output);
         FILE *fout=fopen(output,"w");
         if(fout == (FILE *)NULL) {
                fprintf(stderr,"Unable to open file %s for writing\n",output);
                return EXIT_FAILURE;
         }
         for (int imom=0; imom<Nmom_eq; imom++)
         {
                          for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                          fprintf(fout,"%8.10f \t %8.10f %8.10f  \n",p2[imom],input[imom][Nclust],error_jack_real(aux_clust,Nclust));
        }


        fclose(fout);
        return 0;
}
int write_output_allmomenta_eq_real_LT(char *output, double **input, double *p2, int Nmom_eq_X)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

         printf("Writing in %s\n",output);
         FILE *fout=fopen(output,"w");
         if(fout == (FILE *)NULL) {
                fprintf(stderr,"Unable to open file %s for writing\n",output);
                return EXIT_FAILURE;
         }
         for (int imom=0; imom<Nmom_eq_X; imom++)
         {
                          for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                          fprintf(fout,"%8.10f \t %8.10f %8.10f  \n",p2[imom],input[imom][Nclust],error_jack_real(aux_clust,Nclust));
        }


        fclose(fout);
        return 0;
}

int write_output_momentabymomenta_real(char *dir,char *file, double **input, double *p2, int Nmom)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

        printf("Writing %s momenta by momenta in %s\n",file,dir);
        char outputmom[1024];

        // jk
         for (int imom=0; imom<Nmom; imom++)
         {
                sprintf(outputmom,"%s/p%03d/%s.jk",dir,imom,file);
                FILE *fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

//                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f \n",input[imom][iclust]);
                 fclose(fout);
        }
        // dat

         for (int imom=0; imom<Nmom; imom++)
         {
                sprintf(outputmom,"%s/p%03d/%s.dat",dir,imom,file);
                FILE *fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                 fprintf(fout,"%8.10f %8.10f %8.10f \n",p2[imom],input[imom][Nclust],error_jack_real(aux_clust,Nclust));
                 fclose(fout);
        }

        return 0;
}
int write_output_momentabymomenta_eq_real(char *dir,char *file, double **input, double *p2)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

         printf("Writing %s momenta by momenta in %s\n",file,dir);
         char outputmom[1024];

        // jk
         for (int imom=0; imom<Nmom_eq; imom++)
         {
                sprintf(outputmom,"%s/p%03d/%s.jk",dir,imom,file);
                FILE *fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

//                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f \n",input[imom][iclust]);
                 fclose(fout);
        }
        // dat

         for (int imom=0; imom<Nmom_eq; imom++)
         {
                sprintf(outputmom,"%s/p%03d/%s.dat",dir,imom,file);
                FILE *fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                 fprintf(fout,"%8.10f %8.10f %8.10f \n",p2[imom],input[imom][Nclust],error_jack_real(aux_clust,Nclust));
                 fclose(fout);
        }

        return 0;
}

int write_output_momentabymomenta_eq_real_LT(char *dir,char *file, double **input, double *p2, int Nmom_eq_X)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

         printf("Writing %s momenta by momenta in %s\n",file,dir);
         char outputmom[1024];

        // jk
         for (int imom=0; imom<Nmom_eq_X; imom++)
         {
                sprintf(outputmom,"%s/p%03d/%s.jk",dir,imom,file);
                FILE *fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

//                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f \n",input[imom][iclust]);
                 fclose(fout);
        }
        // dat

         for (int imom=0; imom<Nmom_eq_X; imom++)
         {
                sprintf(outputmom,"%s/p%03d/%s.dat",dir,imom,file);
                FILE *fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[imom][iclust];
                 fprintf(fout,"%8.10f %8.10f %8.10f \n",p2[imom],input[imom][Nclust],error_jack_real(aux_clust,Nclust));
                 fclose(fout);
        }

        return 0;
}

int write_output_onemomenta_real(char *dir,char *file, double *input, double *p2, int imom)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

         printf("Writing %s in %s\n",file,dir);
         char outputmom[1024];
          FILE *fout=NULL;
        // jk
                sprintf(outputmom,"%s/p%03d/%s.jk",dir,imom,file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f \n",input[iclust]);
                 fclose(fout);
        // dat

                sprintf(outputmom,"%s/p%03d/%s.dat",dir,imom,file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[iclust];
                 fprintf(fout,"%8.10f %8.10f %8.10f \n",p2[imom],input[Nclust],error_jack_real(aux_clust,Nclust));
                 fclose(fout);

        return 0;
}
int write_output_onemomenta(char *dir,char *file, complex *input, double *p2, int imom)
{
         complex *aux_clust=malloc(sizeof(complex)*(Nclust+1));

//         printf("Writing %s in %s\n",file,dir);
         char outputmom[1024];
          FILE *fout=NULL;
        // jk
                sprintf(outputmom,"%s/p%03d/%s.jk",dir,imom,file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f  %8.10f\n",creal(input[iclust]),cimag(input[iclust]));
                 fclose(fout);
        // dat

                sprintf(outputmom,"%s/p%03d/%s.dat",dir,imom,file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[iclust];
                          fprintf(fout,"%8.10f \t %8.10f %8.10f  + I %8.10f %8.10f \n",p2[imom],creal(input[Nclust]),creal(error_jack(aux_clust,Nclust)),cimag(input[Nclust]),cimag(error_jack(aux_clust,Nclust)));
                 fclose(fout);

        return 0;
}

int write_output_fixedmomenta_real(char *file, double *input, double *p2, int imom)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

//         printf("Writing %s in %s\n",file,dir);
         char outputmom[1024];
          FILE *fout=NULL;
        // jk
                sprintf(outputmom,"%s.jk",file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f \n",input[iclust]);
                 fclose(fout);
        // dat

                sprintf(outputmom,"%s.dat",file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[iclust];
                 fprintf(fout,"%8.10f %8.10f %8.10f \n",p2[imom],input[Nclust],error_jack_real(aux_clust,Nclust));
                 fclose(fout);

        return 0;
}
int write_output_nomomenta_real(char *file, double *input)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

//         printf("Writing %s in %s\n",file,dir);
         char outputmom[1024];
          FILE *fout=NULL;
        // jk
                sprintf(outputmom,"%s.jk",file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f \n",input[iclust]);
                 fclose(fout);
        // dat

                sprintf(outputmom,"%s.dat",file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[iclust];
                 fprintf(fout,"%8.10f %8.10f \n",input[Nclust],error_jack_real(aux_clust,Nclust));
                 fclose(fout);

        return 0;
}

int write_output_fitmomenta_real(char *file, double *input, double p2min, double p2max, double cut)
{
         double *aux_clust=malloc(sizeof(double)*(Nclust+1));

         printf("Writing %s \n",file);
         char outputmom[1024];
          FILE *fout=NULL;
        // jk
                sprintf(outputmom,"%s.jk",file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) fprintf(fout,"%8.10f \n",input[iclust]);
                 fclose(fout);
        // dat

                sprintf(outputmom,"%s.dat",file);
                fout=fopen(outputmom,"w");
                if(fout == (FILE *)NULL) {
                        fprintf(stderr,"Unable to open file %s for writing\n",outputmom);
                        return EXIT_FAILURE;
                 }

                 for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=input[iclust];
                 fprintf(fout,"%8.10f %8.10f %8.2f %8.2f %8.2f\n",input[Nclust],error_jack_real(aux_clust,Nclust), p2min, p2max,cut);
                 fclose(fout);

        return 0;
}

int write_output_chiral_extrapolation(char *dir,char *file,int imom,double *Z,double **Z_CLUST,double *M,int Nmass,double *ZCHI,double *ZLIN,double *GP,double *chi2)
{
	char outputext[1024];
        double *aux_clust=malloc(sizeof(double)*(Nclust+1));


	FILE *fout=NULL;
	sprintf(outputext,"%s/p%03d/%s.ext",dir,imom,file);
//	printf("writng in %s\n",outputext);
	fout=fopen(outputext,"w");

        if(fout == (FILE *)NULL) {
                 fprintf(stderr,"Unable to open file %s for writing\n",outputext);
                 return EXIT_FAILURE;
         }

	for (int imass=0; imass<Nmass; imass++)
	{
		for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=Z_CLUST[imass][iclust];
		fprintf(fout,"%8.10f %8.10f %8.10f \n",M[imass], Z[imass], error_jack_real(aux_clust,Nclust));
	}
        fprintf(fout,"%8.10f %8.10f \n", ZCHI[Nclust], error_jack_real(ZCHI,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", ZLIN[Nclust], error_jack_real(ZLIN,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", GP[Nclust], error_jack_real(GP,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", chi2[Nclust], error_jack_real(chi2,Nclust));

        fclose(fout);

	return 0;

	
}

int write_output_chiral_extrapolation_0GP(char *dir,char *file,int imom,double *Z,double **Z_CLUST,double *M,int Nmass,double *ZCHI,double *ZLIN,double *chi2)
{
        char outputext[1024];
        double *aux_clust=malloc(sizeof(double)*(Nclust+1));


        FILE *fout=NULL;
        sprintf(outputext,"%s/p%03d/%s.ext",dir,imom,file);
//      printf("writng in %s\n",outputext);
        fout=fopen(outputext,"w");

        if(fout == (FILE *)NULL) {
                 fprintf(stderr,"Unable to open file %s for writing\n",outputext);
                 return EXIT_FAILURE;
         }

        for (int imass=0; imass<Nmass; imass++)
        {
                for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=Z_CLUST[imass][iclust];
                fprintf(fout,"%8.10f %8.10f %8.10f \n",M[imass], Z[imass], error_jack_real(aux_clust,Nclust));
        }
        fprintf(fout,"%8.10f %8.10f \n", ZCHI[Nclust], error_jack_real(ZCHI,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", ZLIN[Nclust], error_jack_real(ZLIN,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", chi2[Nclust], error_jack_real(chi2,Nclust));

        fclose(fout);

        return 0;


}
int write_output_chiral_extrapolation_1GP(char *dir,char *file,int imom,double *Z,double **Z_CLUST,double *M,int Nmass,double *ZCHI,double *ZLIN,double *GP,double *chi2)
{
        char outputext[1024];
        double *aux_clust=malloc(sizeof(double)*(Nclust+1));


        FILE *fout=NULL;
        sprintf(outputext,"%s/p%03d/%s.ext",dir,imom,file);
//      printf("writng in %s\n",outputext);
        fout=fopen(outputext,"w");

        if(fout == (FILE *)NULL) {
                 fprintf(stderr,"Unable to open file %s for writing\n",outputext);
                 return EXIT_FAILURE;
         }

        for (int imass=0; imass<Nmass; imass++)
        {
                for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=Z_CLUST[imass][iclust];
                fprintf(fout,"%8.10f %8.10f %8.10f \n",M[imass], Z[imass], error_jack_real(aux_clust,Nclust));
        }
        for (int imass=0; imass<Nmass; imass++)
        {
                for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=Z_CLUST[imass][iclust]-GP[iclust]/M[imass];
                fprintf(fout,"%8.10f %8.10f %8.10f \n",M[imass], Z[imass]-GP[Nclust]/M[imass], error_jack_real(aux_clust,Nclust));
        }

        fprintf(fout,"%8.10f %8.10f \n", ZCHI[Nclust], error_jack_real(ZCHI,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", ZLIN[Nclust], error_jack_real(ZLIN,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", GP[Nclust], error_jack_real(GP,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", chi2[Nclust], error_jack_real(chi2,Nclust));

        fclose(fout);

        return 0;


}
int write_output_chiral_extrapolation_2GP(char *dir,char *file,int imom,double *Z,double **Z_CLUST,double *M,int Nmass,double *ZCHI,double *ZLIN,double *GP1, double *GP2,double *chi2)
{
        char outputext[1024];
        double *aux_clust=malloc(sizeof(double)*(Nclust+1));


        FILE *fout=NULL;
        sprintf(outputext,"%s/p%03d/%s.ext",dir,imom,file);
//      printf("writng in %s\n",outputext);
        fout=fopen(outputext,"w");

        if(fout == (FILE *)NULL) {
                 fprintf(stderr,"Unable to open file %s for writing\n",outputext);
                 return EXIT_FAILURE;
         }

        for (int imass=0; imass<Nmass; imass++)
        {
                for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=Z_CLUST[imass][iclust];
                fprintf(fout,"%8.10f %8.10f %8.10f \n",M[imass], Z[imass], error_jack_real(aux_clust,Nclust));
        }
        for (int imass=0; imass<Nmass; imass++)
        {
                for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=Z_CLUST[imass][iclust]-GP1[iclust]/M[imass]-GP2[iclust]/pow(M[imass],2);
                fprintf(fout,"%8.10f %8.10f %8.10f \n",M[imass], Z[imass]-GP1[Nclust]/M[imass]-GP2[Nclust]/pow(M[imass],2), error_jack_real(aux_clust,Nclust));
        }

        fprintf(fout,"%8.10f %8.10f \n", ZCHI[Nclust], error_jack_real(ZCHI,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", ZLIN[Nclust], error_jack_real(ZLIN,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", GP1[Nclust], error_jack_real(GP1,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", GP2[Nclust], error_jack_real(GP2,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", chi2[Nclust], error_jack_real(chi2,Nclust));

        fclose(fout);

        return 0;


}

int write_output_sea_chiral_extrapolation(char *file,int imom,double *Z,double **Z_CLUST,double *M,int Nmass,double *ZCHI,double *ZLIN,double *chi2)
{
        double *aux_clust=malloc(sizeof(double)*(Nclust+1));


        FILE *fout=NULL;
       //printf("writng in %s\n",outputext);
        fout=fopen(file,"w");

        if(fout == (FILE *)NULL) {
                 fprintf(stderr,"Unable to open file %s for writing\n",file);
                 return EXIT_FAILURE;
         }

        for (int imass=0; imass<Nmass; imass++)
        {
                for (int iclust=0; iclust<Nclust+1; iclust++) aux_clust[iclust]=Z_CLUST[imass][iclust];
                fprintf(fout,"%8.10f %8.10f %8.10f \n",M[imass], Z[imass], error_jack_real(aux_clust,Nclust));
        }
        fprintf(fout,"%8.10f %8.10f \n", ZCHI[Nclust], error_jack_real(ZCHI,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", ZLIN[Nclust], error_jack_real(ZLIN,Nclust));
        fprintf(fout,"%8.10f %8.10f \n", chi2[Nclust], error_jack_real(chi2,Nclust));

        fclose(fout);

        return 0;


}

